<%@page import="dao.Course"%>
<%@page import="beans.Coursebean"%>
<%@page import="dao.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>修改课程</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body {
	font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	text-align: center;
	background: #E6EAE9;
}

#container {
	margin-left: auto;
	margin-right: auto;
	width: 550px;
	height: 400px;
	background: #f8f8f8;
	border: 2px solid #777;
	display: block;
	vertical-align: middle;
}

.ele {
	margin-top: 30px;
	margin-botton: 30px;
	text-align: center;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
<script type="text/javascript">
function checkData(){
	var counts = document.getElementById("counts").value.trim();
	if(counts !=""){	
		if(!isNaN(counts)){
			return true;
		}			
	}else{
		alert("请填写完整！");
		return false;
	}
}
function checkNumber(number){
	if(!isNaN(number)){
		var num = parseint(number);
		if(num < 0){
			alert("章节数是大于0的数字");
			courseForm.counts.focus();
		}else if(num > 12){
			var res = confirm("输入的数字较大，是否修改？");
			if(res == true){
				courseForm.counts.focus();
			}			
		}				
	}else{
		alert("章节数是数字");
	}
	
}
</script>
</head>

<body>
<%
	//String courseId = (Course)session.getAttribute("course");
	//Coursebean coursebean = new Coursebean();
	Course course = (Course)session.getAttribute("course");;
	String courseid="",name="",des="";
	int counts = 0;
	if(course !=null){
	    courseid = course.getCourseid();
	    name = course.getName();
	    des = course.getDescription();
	    counts = course.getChaptercounts();
	}
%>
	<h2>修改科目</h2>
	<div id="container">
		<form name="courseForm" method="post"
			action="./servlet/CourseManageServlet?action=modify"
			onsubmit="return checkData()">
			<div class="ele">
				<label> 科目编号： </label> <input type="text" name="courseId"
					id="courseId" value="<%=courseid %>" readonly="readonly">
			</div>
			<div class="ele">
				<label> 科目名称： </label> <input type="text" name="courseName"
					id="courseName" value="<%=name %>" readonly="readonly">
			</div>
			<div class="ele">
				<label> 科目描述： </label>
				<textarea id="describe1" name="describe1" rows="8" cols="50""><%=des %></textarea>
			</div>
			<div class="ele">
				<label> 科目章节总数： </label> <input type="text" id="counts"
					onblur="checkNumber(this.value)" name="counts" value="<%=counts %>">
			</div>
			<div class="ele">
				<input type="submit" value="提交"> <input type="reset"
					value="取消">
			</div>
		</form>
	</div>
	<%
	    if (request.getAttribute("success") != null) {
			String str = (String) request.getAttribute("success");
			if (str.equals("true"))
			    out.write("<script>alert('修改成功！')</script>");
			else
			    out.write("<script>alert('修改失败！')</script>");
	    }
	%>
</body>
</html>
